import FlowGraph from "../../../graph";
import Store from '../../../../../store'

export function nodeOpt(id){
    let curCel = null;
    if (id) {
        const { graph } = FlowGraph
        const cell = graph.getCellById(id)
        if (!cell || !cell.isNode()) {
            return
        }
        curCel = cell
        Store.commit('flow/updatenodeStroke', cell.attr('body/stroke'))
        Store.commit('flow/updatenodeStrokeWidth', cell.attr('body/strokeWidth'))
        Store.commit('flow/updatenodeFill', cell.attr('body/fill'))
        Store.commit('flow/updatenodeFontSize', cell.attr('text/fontSize'))
        Store.commit('flow/updatenodeColor', cell.attr('text/fill'))
        Store.commit('flow/updateportId', '')
        Store.commit('flow/updatenodeLabel', cell.attr('text/text'))
        Store.commit('flow/updatenodeBackgroundColor', cell.attr('body/fill'))
        Store.commit('flow/updatenodeTitle', cell.attr('title/text'))
        Store.commit('flow/updatenodeImg', cell.attr('image/xlink:href'))
        Store.commit('flow/updatenodeHeadHeight', cell.attr('head/Height'))
        Store.commit('flow/updatenodeTitleFontSize', cell.attr('title/fontSize'))
        Store.commit('flow/updateNodeHeadX', cell.attr('title/refX'))
        Store.commit('flow/updateNodeHeadY', cell.attr('title/refY'))
        Store.commit('flow/updateNodeTextX', cell.attr('text/refX'))
        Store.commit('flow/updateNodeTextY', cell.attr('text/refY'))
        Store.commit('flow/updateLineSolid', cell.attr('body/strokeDasharray'))

    }
    return curCel;
}
